import 'package:coinbaby/common/alert/alert.dart';
import 'package:coinbaby/common/const/cosnt.dart';
import 'package:coinbaby/common/textstyle/textstyle.dart';
import 'package:coinbaby/page/autobuy/view/bottom_buttom.dart';
import 'package:coinbaby/page/autobuy/view/select_strategy.dart';
import 'package:coinbaby/page/autobuy/view/select_tab.dart';
import 'package:coinbaby/page/autobuy/view/strategy_info.dart';
import 'package:flutter/material.dart';

class CreateStrategy extends StatefulWidget {
  @override
  _CreateStrategyState createState() => _CreateStrategyState();
}

class _CreateStrategyState extends State<CreateStrategy> with SingleTickerProviderStateMixin {

  static const List<String> titles = ["启动设置", "高级设置"];
  TabController _tabController;
  int currIndex = 0;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(vsync: this, length: 2);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: Colors.white,
        elevation: 0,
        leading: IconButton(
          padding: const EdgeInsets.all(0),
          icon: Image.asset("assets/icon_zuo.png"),
          onPressed: () => Navigator.pop(context),
        ),
        title: SizedBox(
          width: size.width,
          child: SelectTabView(
            titles: titles,
            horizontal: 50,
            paddingTop: 10,
            tabController: _tabController,
            currentIndex: currIndex,
            onTap: (index) {
              if(index > 0) {
                Alert.showToast("未开放,敬请期待");
                return;
              }
              setState(() {
                currIndex = index;
              });
            },
          ),
        ),
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 15),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            SizedBox(height: 15,),
            Text("启动前必读:", style: AppFont.textStyle(15, AppColor.red),),
            SizedBox(height: 10,),
            Text.rich(
              TextSpan(
                children: [
                  TextSpan(text: "1.账户余额要求USDT≥1000，BTC≥10才可进行。", style: AppFont.textStyle(15, AppColor.red)),
                  TextSpan(
                    text: "\n2.介绍启动介绍启动介绍启动介绍启动介绍启动介绍。\n3.币小贝启动介绍启动介绍启动介绍启动介绍启动介绍启动介绍币小贝启动介绍启动介绍启动介绍启动介绍启动介绍启动介绍。",
                    style: AppFont.textStyle(14, AppColor.fontgrey)
                  )
                ]
              )
            ),
            SelectStrategy(),
            StrategyInfoView(),
            Spacer(),
            BottomButton(title: "我已经阅读上述事项，确认启动",)
          ],
        ),
      ),
    );
  }
}